using System;
using System.Collections;
using System.DirectoryServices;

namespace BEGDC.CC.Entity
{
	#region EVMeetingAttendee

	/// <summary>
	/// EVMeetingAttendee object for NHibernate mapped table 'EVMeetingAttendee'.
	/// </summary>
	[Serializable]
	public class EVMeetingAttendee : System.IComparable
		{
		#region Member Variables
		
		protected int _id;
		protected string _nameCN;
		protected string _nameEN;
		protected string _company;
		protected string _title;
		protected string _department;
		protected EVMeeting _eVMeeting;
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public EVMeetingAttendee() { }

		public EVMeetingAttendee( string nameCN, string nameEN, string company, string title, EVMeeting eVMeeting, string department )
		{
			this._nameCN = nameCN;
			this._nameEN = nameEN;
			this._company = company;
			this._title = title;
			this._eVMeeting = eVMeeting;
			this._department = department;
		}

		#endregion

		#region Public Properties

		public int Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public string NameCN
		{
			get { return _nameCN; }
			set
			{
				if ( value != null && value.Length > 20)
					throw new ArgumentOutOfRangeException("Invalid value for NameCN", value, value.ToString());
				_nameCN = value;
			}
		}

		public string NameEN
		{
			get { return _nameEN; }
			set
			{
				if ( value != null && value.Length > 100)
					throw new ArgumentOutOfRangeException("Invalid value for NameEN", value, value.ToString());
				_nameEN = value;
			}
		}

		public string Company
		{
			get { return _company; }
			set
			{
				if ( value != null && value.Length > 250)
					throw new ArgumentOutOfRangeException("Invalid value for Company", value, value.ToString());
				_company = value;
			}
		}

		public string Title
		{
			get { return _title; }
			set
			{
				if ( value != null && value.Length > 250)
					throw new ArgumentOutOfRangeException("Invalid value for Title", value, value.ToString());
				_title = value;
			}
		}

		public string Department
		{
			get { return _department; }
			set
			{
				if ( value != null && value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for department", value, value.ToString());
				_department = value;
			}
		}

		public EVMeeting EVMeeting
		{
			get { return _eVMeeting; }
			set { _eVMeeting = value; }
		}

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public int CompareTo(object obj)
        {
			if (!(obj is EVMeetingAttendee))
				throw new InvalidCastException("This object is not of type EVMeetingAttendee");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((EVMeetingAttendee)obj).Id);
					break;
				case "NameCN":
						relativeValue = ( this.NameCN != null ) ? this.NameCN.CompareTo(((EVMeetingAttendee)obj).NameCN) : -1;
					break;
				case "NameEN":
						relativeValue = ( this.NameEN != null ) ? this.NameEN.CompareTo(((EVMeetingAttendee)obj).NameEN) : -1;
					break;
				case "Company":
						relativeValue = ( this.Company != null ) ? this.Company.CompareTo(((EVMeetingAttendee)obj).Company) : -1;
					break;
				case "Title":
						relativeValue = ( this.Title != null ) ? this.Title.CompareTo(((EVMeetingAttendee)obj).Title) : -1;
					break;
                default:
                    goto case "Id";
			}
            if (EVMeetingAttendee.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
